<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <style>
        .resource-box {
            width: 100%;
            display: flex;
            flex-wrap: wrap;
        }

        .resource-item {
            display: flex;
            padding: 5px 10px;
        }

        .table-box .el-table__header .el-table-column–selection .cell:after {
            color: white;
            content: "菜单";
            margin-left: 10px;
        }
    </style>
</head>

<body>
    <div id="app">
        <div style="margin-top: 20px;">
            <el-checkbox v-model="checked" @change="allCheckChange"> 全选 </el-checkbox>
            <el-button @click="getCheckedData">获取所选择数据</el-button>
        </div>
        <el-table :data="tableData" ref="tableTree" style="width: 100%;margin-bottom: 20px;" row-key="id"
            :header-cell-style="{ textAlign: 'center',backgroundColor:'#f9f9f9' }" border default-expand-all
            :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
            <el-table-column prop="" label="菜单" width="360">
                <template slot-scope="scope">
                    <el-checkbox v-model="scope.row.checked" :indeterminate="scope.row.indeterminate"
                        :label="scope.row.name" :key="scope.row.id"
                        @change="nodeChangeCheck(scope.row)">{{scope.row.id}}</el-checkbox>
                </template>
            </el-table-column>
            <el-table-column prop="" label="资源">
                <template slot-scope="scope">
                    <div class="resource-box">
                        <div class="resource-item" v-for="(item, index) in scope.row.resourceList" :key="index">
                            <el-checkbox v-model="item.checked" :label="item.name" :key="item.id"
                                @change="handlerResourceChange(scope.row, item)">{{item.id}}</el-checkbox>
                        </div>
                    </div>

                </template>
            </el-table-column>
        </el-table>
    </div>
</body>
<!-- import Vue before Element -->
<script src="https://unpkg.com/vue@2/dist/vue.js"></script>
<!-- import JavaScript -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script>
    /*:indeterminate="scope.row.indeterminate"*/
    var that;
    new Vue({
        el: '#app',
        data: function () {

            return {
                // 模拟后台返回  表格数据
                tableData: [
                    {
                        id: 1,
                        pid: 0,
                        name: "应用功能区",
                        checked: false,
                        indeterminate: false, 
                        resourceList:[],
                        children: [
                            {
                                id: 11,
                                pid: 1,
                                name: "综合管理",
                                checked: false,
                                indeterminate: false, 
                        resourceList:[],
                                children: [
                                    {
                                        id: 111,
                                        pid: 11,
                                        name: "工程划分管理",
                                        checked: false,
                                        indeterminate: false, 
                        resourceList:[],
                                        children: [
                                            {
                                                id: 1111,
                                                pid: 111,
                                                name: "工程概况",
                                                checked: false,
                                                indeterminate: false,
                                                resourceList: [
                                                    { id: 11111, name: "列表", checked: false },
                                                    { id: 11112, name: "新增", checked: false },
                                                    { id: 11113, name: "修改", checked: false },
                                                    { id: 11114, name: "保存", checked: false },
                                                    { id: 11115, name: "删除", checked: false },
                                                ],
                                                children: [],
                                            },
                                            {
                                                id: 1112,
                                                pid: 111,
                                                name: "工程概况1",
                                                checked: false,
                                                indeterminate: false,
                                                resourceList: [
                                                    { id: 11121, name: "列表", checked: false },
                                                    { id: 11122, name: "新增", checked: false },
                                                    { id: 11123, name: "修改", checked: false },
                                                    { id: 11124, name: "保存", checked: false },
                                                    { id: 11125, name: "删除", checked: false },
                                                ],
                                                children: [],
                                            },
                                        ],
                                    },
                                    {
                                        id: 112,
                                        pid: 11,
                                        name: "工程划分管理",
                                        checked: false,
                                        indeterminate: false, 
                        resourceList:[],
                                        children: [
                                            {
                                                id: 1121,
                                                pid: 112,
                                                name: "工程概况",
                                                checked: false,
                                                indeterminate: false,
                                                resourceList: [
                                                    { id: 11211, name: "列表", checked: false },
                                                    { id: 11212, name: "新增", checked: false },
                                                    { id: 11213, name: "修改", checked: false },
                                                    { id: 11214, name: "保存", checked: false },
                                                    { id: 11215, name: "删除", checked: false },
                                                ],
                                                children: [],
                                            },
                                            {
                                                id: 1122,
                                                pid: 112,
                                                name: "工程概况1",
                                                checked: false,
                                                indeterminate: false,
                                                resourceList: [
                                                    { id: 11221, name: "列表", checked: false },
                                                    { id: 11222, name: "新增", checked: false },
                                                    { id: 11223, name: "修改", checked: false },
                                                    { id: 11224, name: "保存", checked: false },
                                                    { id: 11225, name: "删除", checked: false },
                                                ],
                                                children: [],
                                            },
                                        ],
                                    },
                                ],
                            },
                            {
                                id: 12,
                                pid: 1,
                                name: "综合管理",
                                checked: false,
                                indeterminate: false, 
                        resourceList:[],
                                children: [
                                    {
                                        id: 121,
                                        pid: 12,
                                        name: "工程划分管理",
                                        checked: false,
                                        indeterminate: false, 
                        resourceList:[],
                                        children: [
                                            {
                                                id: 1211,
                                                pid: 121,
                                                name: "工程概况",
                                                checked: false,
                                                indeterminate: false,
                                                resourceList: [
                                                    { id: 12111, name: "列表", checked: false },
                                                    { id: 12112, name: "新增", checked: false },
                                                    { id: 12113, name: "修改", checked: false },
                                                    { id: 12114, name: "保存", checked: false },
                                                    { id: 12115, name: "删除", checked: false },
                                                ],
                                                children: [],
                                            },
                                            {
                                                id: 1212,
                                                pid: 121,
                                                name: "工程概况1",
                                                checked: false,
                                                indeterminate: false,
                                                resourceList: [
                                                    { id: 12121, name: "列表", checked: false },
                                                    { id: 12122, name: "新增", checked: false },
                                                    { id: 12123, name: "修改", checked: false },
                                                    { id: 12124, name: "保存", checked: false },
                                                    { id: 12125, name: "删除", checked: false },
                                                ],
                                                children: [],
                                            },
                                        ],
                                    },
                                    {
                                        id: 122,
                                        pid: 12,
                                        name: "工程划分管理",
                                        checked: false,
                                        indeterminate: false, 
                        resourceList:[],
                                        children: [
                                            {
                                                id: 1221,
                                                pid: 122,
                                                name: "工程概况",
                                                checked: false,
                                                indeterminate: false,
                                                resourceList: [
                                                    { id: 12211, name: "列表", checked: false },
                                                    { id: 12212, name: "新增", checked: false },
                                                    { id: 12213, name: "修改", checked: false },
                                                    { id: 12214, name: "保存", checked: false },
                                                    { id: 12215, name: "删除", checked: false },
                                                ],
                                                children: [],
                                            },
                                            {
                                                id: 1222,
                                                pid: 122,
                                                name: "工程概况1",
                                                checked: false,
                                                indeterminate: false,
                                                resourceList: [
                                                    { id: 12221, name: "列表", checked: false },
                                                    { id: 12222, name: "新增", checked: false },
                                                    { id: 12223, name: "修改", checked: false },
                                                    { id: 12224, name: "保存", checked: false },
                                                    { id: 12225, name: "删除", checked: false },
                                                ],
                                                children: [],
                                            },
                                        ],
                                    },
                                ],
                            },
                        ],
                    },
                    {
                        id: 2,
                        pid: 0,
                        name: "应用功能区",
                        checked: false,
                        indeterminate: false, 
                        resourceList:[],
                        children: [
                            {
                                id: 21,
                                pid: 2,
                                name: "综合管理",
                                checked: false,
                                indeterminate: false, 
                        resourceList:[],
                                children: [
                                    {
                                        id: 211,
                                        pid: 21,
                                        name: "工程划分管理",
                                        checked: false,
                                        indeterminate: false, 
                        resourceList:[],
                                        children: [
                                            {
                                                id: 2111,
                                                pid: 211,
                                                name: "工程概况",
                                                checked: false,
                                                indeterminate: false,
                                                resourceList: [
                                                    { id: 21111, name: "列表", checked: false },
                                                    { id: 21112, name: "新增", checked: false },
                                                    { id: 21113, name: "修改", checked: false },
                                                    { id: 21114, name: "保存", checked: false },
                                                    { id: 21115, name: "删除", checked: false },
                                                ],
                                                children: [],
                                            },
                                            {
                                                id: 2112,
                                                pid: 211,
                                                name: "工程概况1",
                                                checked: false,
                                                indeterminate: false,
                                                resourceList: [
                                                    { id: 21111, name: "列表", checked: false },
                                                    { id: 21112, name: "新增", checked: false },
                                                    { id: 21113, name: "修改", checked: false },
                                                    { id: 21114, name: "保存", checked: false },
                                                    { id: 21115, name: "删除", checked: false },
                                                ],
                                                children: [],
                                            },
                                        ],
                                    },
                                    {
                                        id: 212,
                                        pid: 21,
                                        name: "工程划分管理",
                                        checked: false,
                                        indeterminate: false, 
                        resourceList:[],
                                        children: [
                                            {
                                                id: 2121,
                                                pid: 212,
                                                name: "工程概况",
                                                checked: false,
                                                indeterminate: false,
                                                resourceList: [
                                                    { id: 21211, name: "列表", checked: false },
                                                    { id: 21212, name: "新增", checked: false },
                                                    { id: 21213, name: "修改", checked: false },
                                                    { id: 21214, name: "保存", checked: false },
                                                    { id: 21215, name: "删除", checked: false },
                                                ],
                                                children: [],
                                            },
                                            {
                                                id: 2122,
                                                pid: 212,
                                                name: "工程概况1",
                                                checked: false,
                                                indeterminate: false,
                                                resourceList: [
                                                    { id: 21221, name: "列表", checked: false },
                                                    { id: 21222, name: "新增", checked: false },
                                                    { id: 21223, name: "修改", checked: false },
                                                    { id: 21224, name: "保存", checked: false },
                                                    { id: 21225, name: "删除", checked: false },
                                                ],
                                                children: [],
                                            },
                                        ],
                                    },
                                ],
                            },
                            {
                                id: 22,
                                pid: 2,
                                name: "综合管理",
                                checked: false,
                                indeterminate: false, 
                        resourceList:[],
                                children: [
                                    {
                                        id: 221,
                                        pid: 22,
                                        name: "工程划分管理",
                                        checked: false,
                                        indeterminate: false, 
                        resourceList:[],
                                        children: [
                                            {
                                                id: 2211,
                                                pid: 221,
                                                name: "工程概况",
                                                checked: false,
                                                indeterminate: false,
                                                resourceList: [
                                                    { id: 22111, name: "列表", checked: false },
                                                    { id: 22112, name: "新增", checked: false },
                                                    { id: 22113, name: "修改", checked: false },
                                                    { id: 22114, name: "保存", checked: false },
                                                    { id: 22115, name: "删除", checked: false },
                                                ],
                                                children: [],
                                            },
                                            {
                                                id: 2212,
                                                pid: 221,
                                                name: "工程概况1",
                                                checked: false,
                                                indeterminate: false,
                                                resourceList: [
                                                    { id: 22121, name: "列表", checked: false },
                                                    { id: 22122, name: "新增", checked: false },
                                                    { id: 22123, name: "修改", checked: false },
                                                    { id: 22124, name: "保存", checked: false },
                                                    { id: 22125, name: "删除", checked: false },
                                                ],
                                                children: [],
                                            },
                                        ],
                                    },
                                    {
                                        id: 222,
                                        pid: 22,
                                        name: "工程划分管理",
                                        checked: false,
                                        indeterminate: false, 
                        resourceList:[],
                                        children: [
                                            {
                                                id: 2221,
                                                pid: 222,
                                                name: "工程概况",
                                                checked: false,
                                                indeterminate: false,
                                                resourceList: [
                                                    { id: 22211, name: "列表", checked: false },
                                                    { id: 22212, name: "新增", checked: false },
                                                    { id: 22213, name: "修改", checked: false },
                                                    { id: 22214, name: "保存", checked: false },
                                                    { id: 22215, name: "删除", checked: false },
                                                ],
                                                children: [],
                                            },
                                            {
                                                id: 2222,
                                                pid: 222,
                                                name: "工程概况1",
                                                checked: false,
                                                indeterminate: false,
                                                resourceList: [
                                                    { id: 22221, name: "列表", checked: false },
                                                    { id: 22222, name: "新增", checked: false },
                                                    { id: 22223, name: "修改", checked: false },
                                                    { id: 22224, name: "保存", checked: false },
                                                    { id: 22225, name: "删除", checked: false },
                                                ],
                                                children: [],
                                            },
                                        ],
                                    },
                                ],
                            },
                        ],
                    },
                    {
                        id: 3,
                        pid: 0,
                        name: "应用功能区3",
                        checked: false,
                        indeterminate: false, 
                        resourceList:[],
                        children: [
                            {
                                id: 31,
                                pid: 3,
                                name: "应用功能区31",
                                checked: false,
                                indeterminate: false, 
                        resourceList:[],
                                children: []
                            },
                            {
                                id: 32,
                                pid: 3,
                                name: "应用功能区31",
                                checked: false,
                                indeterminate: false, 
                        resourceList:[],
                                children: []
                            }
                        ]
                    }
                ],
                // 选中的资源记录
                rowMultipleSelection: [],
                // 全选标志
                checked: false,
                // 模拟后台返回 已选中数据
                checkedData: [{"menuId":1,"resourceId":""},{"menuId":11,"resourceId":""},{"menuId":111,"resourceId":""},{"menuId":1111,"resourceId":11111},{"menuId":1112,"resourceId":11122},{"menuId":112,"resourceId":""},{"menuId":1121,"resourceId":11211},{"menuId":1121,"resourceId":11212},{"menuId":1121,"resourceId":11213},{"menuId":1121,"resourceId":11214},{"menuId":1121,"resourceId":11215},{"menuId":1122,"resourceId":11221},{"menuId":1122,"resourceId":11222},{"menuId":1122,"resourceId":11223},{"menuId":1122,"resourceId":11224},{"menuId":1122,"resourceId":11225},{"menuId":2,"resourceId":""},{"menuId":21,"resourceId":""},{"menuId":211,"resourceId":""},{"menuId":2111,"resourceId":21111},{"menuId":2111,"resourceId":21112},{"menuId":2111,"resourceId":21113},{"menuId":2111,"resourceId":21114},{"menuId":2111,"resourceId":21115},{"menuId":2112,"resourceId":21111},{"menuId":2112,"resourceId":21112},{"menuId":2112,"resourceId":21113},{"menuId":2112,"resourceId":21114},{"menuId":2112,"resourceId":21115},{"menuId":212,"resourceId":""},{"menuId":2121,"resourceId":21211},{"menuId":2121,"resourceId":21212},{"menuId":2121,"resourceId":21213},{"menuId":2121,"resourceId":21214},{"menuId":2121,"resourceId":21215},{"menuId":2122,"resourceId":21221},{"menuId":2122,"resourceId":21222},{"menuId":2122,"resourceId":21223},{"menuId":2122,"resourceId":21224},{"menuId":2122,"resourceId":21225},{"menuId":3,"resourceId":""},{"menuId":31,"resourceId":""}]
            }
        },
        created() {
            that = this;
            this.initDataArrFormat(this.tableData);
        },
        methods: {

            // 回显 选中数据
            initDataArrFormat(tableData) {
                if (tableData && tableData.length > 0) {
                    for (var i = 0; i < tableData.length; i++) {
                      let node = tableData[i];
                      let children = node.children;
                      let resourceList = node.resourceList;

                      // 处理 没有子类  没有资源 自己选中的
                      if ((!children || children == 0) && ((!resourceList || resourceList == 0)) && this.haveData(node.id)) {
                        node.checked = true;
                        this.nodeChangeCheck(node);
                      }

                      // children 全部选中
                      if (this.checkedAll(children) == 1) {
                        node.checked = true;
                        this.nodeChangeCheck(node);
                      }

                      // resource 全部选中
                      if (this.haveAllResource(node.id, resourceList.length)) {
                        node.checked = true;
                        this.nodeChangeCheck(node);
                      } else {
                        // 判断 resourceList 是否有选中的
                        if (resourceList && resourceList.length > 0) {
                          for (let j = 0; j < resourceList.length; j++) {
                            let item = resourceList[j];
                            if (this.haveData(item.id)) {
                              item.checked = true;
                              this.handlerResourceChange(node, item);
                            }
                          }
                        }
                      }

                      // 处理 有子类 children  
                      if (children && children.length > 0) {
                        this.initDataArrFormat(children);
                      }
                    }
                  }
            },
            // children 是否全部选中  未选 0 全选 1 半选 2
            checkedAll(arr) {
              let num = 0;
              if (arr && arr.length > 0) {
                for (let i = 0; i < arr.length; i++) {
                  var item = arr[i];
                  if (this.haveData(item.id)) {
                    num++;
                  }
                }
              }
              if (num == 0) {
                return 0;
              }
              if (num == arr.length && this.haveAllResource(item.id, item.resourceList)) {
                return 1;
              }
              if (num > 0 && num != arr.length) {
                return 2;
              }
            },
            // 节点下资源是否全部选中
            haveAllResource(id, total) {
                let checkedData = this.checkedData;
                let num = 0;
                if (checkedData && checkedData.length > 0) {
                    for (var i = 0; i < checkedData.length; i++) {
                        let item = checkedData[i];
                        if (id == item.resourceId) {
                            num++;
                        }
                    }
                }
                return num == total && num > 0 ? true : false;
            },

            // 节点是否选中
            haveData(id) {
                let checkedData = this.checkedData;
                if (checkedData && checkedData.length > 0) {
                    for (var i = 0; i < checkedData.length; i++) {
                        let item = checkedData[i];
                        if (id == item.menuId || id == item.resourceId) {
                            return true;
                        }
                    }
                }
                return false;
            },

            // 全选 反选 change
            allCheckChange(e) {
                this.allCheck(this.tableData, e);
            },

            /* 全选 反选 */
            allCheck(tableData, checked) {
                for (var i = 0; i < tableData.length; i++) {
                    let item = tableData[i];
                    item.indeterminate = false;
                    item.checked = checked;
                    // 资源
                    this.allCheckResource(item.resourceList, checked);
                    // 子集
                    if (item.children && item.children.length > 0) {
                        this.allCheck(item.children, checked);
                    }
                }
            },

            // 资源 全选 反选
            allCheckResource(resourceList, checked) {
                if (resourceList && resourceList.length > 0) {
                    for (var i = 0; i < resourceList.length; i++) {
                        let item = resourceList[i];
                        item.indeterminate = false;
                        item.checked = checked;
                    }
                }
            },

            // 资源选择状态变化
            handlerResourceChange(row, item) {
                let that = this;
                if (item.checked) {
                    // 选中
                    // row 存储
                    that.rowMultipleSelection.push(item.id);
                } else {
                    // 未选中
                    var rowIndex = that.rowMultipleSelection.indexOf(item.id);
                    if (rowIndex > -1) {
                        that.rowMultipleSelection.splice(rowIndex, 1);
                    }
                }
                // 记录选中的数量
                var flag = 0;
                var len = row.resourceList.length;
                /*如果有资源按钮 判断flag过滤玩数组后是否为true */
                if (row.resourceList.length > 0) {
                    for (var i = 0; i < row.resourceList.length; i++) {
                        if (row.resourceList[i].checked) {
                            flag++;
                        }
                    }
                }
                if (flag == len) {
                    //row  全部选中
                    that.rowMultipleSelection.push(row.id);
                    row.checked = true;
                    row.indeterminate = false;
                    if(row.children && row.children.length > 0){
                         // 当前节点的所有子集和资源处理
                         processAllChildAndResourceById(row, row.checked);
                    }
                } else if (flag != len && flag > 0) {
                    //row 部分选中
                    var tableIndex = that.rowMultipleSelection.indexOf(row.id);
                    if (tableIndex > -1) {
                        that.rowMultipleSelection.splice(tableIndex, 1);
                    }
                    row.indeterminate = true;
                    row.checked = false;
                } else if (flag == 0) {
                    //row 全部不选
                    var tableIndex = that.rowMultipleSelection.indexOf(row.id);
                    if (tableIndex > -1) {
                        that.rowMultipleSelection.splice(tableIndex, 1);
                    }
                    row.indeterminate = false;
                    row.checked = false;
                    if(row.children && row.children.length > 0){
                         // 当前节点的所有子集和资源处理
                         processAllChildAndResourceById(row, row.checked);
                    }
                }
                // 当前节点的所有父级id  当前节点的所有父级状态处理
                this.processParentStatus(row);
            },

            /* row 选中 未选中 状态变化 */
            nodeChangeCheck(row) {
                let that = this;
                if (row.checked) {
                    row.indeterminate = false;
                }
                // 当前节点的所有子集和资源处理
                this.processAllChildAndResourceById(row, row.checked);
                // 当前节点的所有父级id  当前节点的所有父级状态处理
                this.processParentStatus(row);
            },

            // 当前节点的所有父级状态处理
            processParentStatus(row) {
                // 当前节点的所有父级id  当前节点的所有父级状态处理
                let pidArr = [];
                let tableData = this.tableData;
                this.processParentChecked(tableData, row.id, pidArr);
                // 是否全部选中  修改全选状态
                let num = 0;
                for (var i = 0; i < tableData.length; i++) {
                    let item = tableData[i];
                    if (item.checked) {
                        num++;
                    }
                }
                if (num == tableData.length) {
                    this.checked = true;
                } else {
                    this.checked = false;
                }

            },

            // 当前节点的所有父级id  当前节点的所有父级状态处理
            processParentChecked(tree, id, parents = []) {
                for (let i = 0; i < tree.length; i++) {
                    const node = tree[i];
                    if (node.id === id) {
                        parents.push(node.id);
                        return parents;
                    } else if (node.children) {
                        const found = this.processParentChecked(node.children, id, parents);
                        if (found) {
                            parents.push(node.id);
                            //父级状态 由子集决定
                            // 子集的状态
                            let status = this.childrenStatus(node);
                            // 判读子集是 未选 0 全选 1 半选 2 
                            if (status == 0) {
                                node.checked = false;
                                node.indeterminate = false;
                            }
                            if (status == 1) {
                                node.checked = true;
                                node.indeterminate = false;
                            }
                            if (status == 2) {
                                node.checked = false;
                                node.indeterminate = true;
                            }
                            return found;
                        }
                    }
                }
                return null;
            },

            // 判读子集是 未选 0 全选 1 半选 2 
            childrenStatus(node) {
                // 计数
                let checkedNum = 0;
                let indeterminateNum = 0;
                if (node.children && node.children.length > 0) {
                    var len = node.children.length;
                    var children = node.children;
                    for (var i = 0; i < children.length; i++) {
                        let item = children[i];
                        if (item.indeterminate) {
                            indeterminateNum++;
                        }
                        if (item.checked) {
                            checkedNum++;
                        }
                    }

                }
                if (checkedNum == len) {
                    // 全选
                    return 1;
                } else if (checkedNum == 0 && indeterminateNum == 0) {
                    // 未选
                    return 0;
                } else {
                    // 半选
                    return 2;
                }
            },

            // 当前节点的所有子集和资源处理
            processAllChildAndResourceById(node, checked) {
                //当前节点 资源
                if (node.resourceList && node.resourceList.length > 0) {
                    this.allCheckResource(node.resourceList, checked);
                }
                if (node.children && node.children.length > 0) {
                    var children = node.children;
                    //子集
                    for (var i = 0; i < children.length; i++) {
                        let item = children[i];
                        item.indeterminate = false;
                        item.checked = checked;
                        //子集资源
                        if (item.resourceList && item.resourceList.length > 0) {
                            this.allCheckResource(item.resourceList, checked);
                        }
                        // 子集为新节点再次遍历
                        this.processAllChildAndResourceById(item, checked);
                    }
                }
            },

            // 获取所有选中数据
            getCheckedData() {
                let idArr = [];
                this.processData(this.tableData, idArr);
                alert(JSON.stringify(idArr));
            },

            // 获取所有选中数据
            processData(tableData, idArr = []) {
                for (var i = 0; i < tableData.length; i++) {
                    let item = tableData[i];
                    // 资源
                    //子集资源
                    if (item.resourceList && item.resourceList.length > 0) {
                        for (var j = 0; j < item.resourceList.length; j++) {
                            let res = item.resourceList[j];
                            if (res.checked) {
                                idArr.push({ menuId: item.id, resourceId: res.id });
                            }
                        }
                    } else {
                        if (item.checked) {
                            idArr.push({ menuId: item.id, resourceId: '' });
                        }
                        if (item.indeterminate) {
                            idArr.push({ menuId: item.id, resourceId: '' });
                        }
                    }
                    // 子集
                    if (item.children && item.children.length > 0) {
                        this.processData(item.children, idArr);
                    }
                }
            }
        }

    })


</script>

</html>